//------------------------------------------------------------------------
// Abstract: Define of class XWrapper
//
// Authoring: XiaoHanxiong
//
// Time: 2014.4.09
//
// Static test:
//
// Version history:
//		Ver_1.0 : 2014.4.09	XiaoHanxiong
//------------------------------------------------------------------------
#ifndef _Library_XWrapper_h_
#define _Library_XWrapper_h_

#include "Stdafx.h"
#include "Memory.h"

namespace Library
{
	class _LIBRARY XWrapper
	{
	public:
		// Default constructor
		XWrapper();
		// Destructor
		~XWrapper();

	public:
		// Push blob into memroy
		void PushBlob(void* blob, size_t size);
		// Get the memory data size
		size_t GetLength();
		// Get the head address of data
		const void* GetData();
		// Seek to begin of data in memory
		void SeekBegin();
		// Seek to end of data in memory
		void SeekEnd();
		// Clear data
		void Clear();
		// Increase the memory front size
		void IncreaseFront(size_t front_size);
		// Increase the memory back size
		void IncreaseBack(size_t back_size);

	public:
		// Input data into memory
		XWrapper& operator << (UINT8 value);
		XWrapper& operator << (UINT16 value);
		XWrapper& operator << (UINT32 value);
		XWrapper& operator << (UINT64 value);
		XWrapper& operator << (INT8 value);
		XWrapper& operator << (INT16 value);
		XWrapper& operator << (INT32 value);
		XWrapper& operator << (INT64 value);
		XWrapper& operator << (float value);
		XWrapper& operator << (double value);
		XWrapper& operator << (string& str);

	public:
		// Output data into memory
		XWrapper& operator >> (UINT8& value);
		XWrapper& operator >> (UINT16& value);
		XWrapper& operator >> (UINT32& value);
		XWrapper& operator >> (UINT64& value);
		XWrapper& operator >> (INT8& value);
		XWrapper& operator >> (INT16& value);
		XWrapper& operator >> (INT32& value);
		XWrapper& operator >> (INT64& value);
		XWrapper& operator >> (float& value);
		XWrapper& operator >> (double& value);
		XWrapper& operator >> (string& str);

	protected:
		// Memory object to store the data
		Memory m_memory;
		// Current cusor in data
		const UINT8* m_cursor;
	};

}// _Library

#endif